# 定义模块名变量
set(MODULE_NAME account)

# 自动收集源文件
file(GLOB_RECURSE ${MODULE_NAME}_SRCS 
    "${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp"
    "${CMAKE_CURRENT_SOURCE_DIR}/src/*.cc"
)

# 添加可执行文件
add_executable(${MODULE_NAME} ${${MODULE_NAME}_SRCS})

# 包含目录
target_include_directories(${MODULE_NAME} PRIVATE
    ${CMAKE_CURRENT_SOURCE_DIR}/include
    ${CMAKE_SOURCE_DIR}/common/include
)

# 静态编译判断条件
if(NOT BUILD_SHARED_LIBS)
    # 显式指定静态库绝对路径
    #set(DCP_STATIC_LIB ${CMAKE_SOURCE_DIR}/common/lib/libdcp.a)
    
    # 确保优先搜索静态库路径
    #link_directories(
    #    ${CMAKE_SOURCE_DIR}/common/lib
    #    BEFORE  # 确保该路径优先于其他路径
    #)
endif()

#find_package(Protobuf REQUIRED)

# 链接依赖
target_link_libraries(${MODULE_NAME} PRIVATE 
	pthread
	cpptools
	dcp5
	mysqlclient 
	mysqlpp
	crypto
	protobuf
	absl_log_internal_message
	absl_log_internal_nullguard
	absl_log_internal_check_op
)

# 模块特定编译选项
target_compile_options(${MODULE_NAME} PRIVATE
#    -D${MODULE_NAME}_MODULE
	-DMYSQLPP_MYSQL_HEADERS_BURIED   # mysql++ 头文件包含
)

# 关键设置：忽略共享库中的未解析符号
#set_target_properties(${MODULE_NAME} PROPERTIES
#  LINK_FLAGS "-Wl,--unresolved-symbols=ignore-in-shared-libs"
#)


add_custom_target(clean_${MODULE_NAME}
    COMMAND ${CMAKE_COMMAND} -E remove_directory ${CMAKE_CURRENT_BINARY_DIR}
    COMMENT "删除connector构建目录"
    VERBATIM
)
